package com.thinktank.controller;

import java.io.*;
import java.sql.*;

import javax.servlet.*;
import javax.servlet.http.*;

import com.thinktank.dao.*;

import static com.thinktank.util.DbUtil.*;

public class NoticeDeleteController implements Controller {

	@Override
	public String execute(HttpServletRequest request,
			HttpServletResponse response) throws IOException, ServletException {
		// 정보 받고 DB 작업하고 에러면 error.jsp로
		String seq = request.getParameter("seq");
		Connection con = getConnection();
		NoticeDao dao = new NoticeDao(con);

		int result = dao.delete(seq);
		close(con);
		
		if(result == 0)		return "error.jsp";
		else 				return "redirect:notice.do?p=2";
	}

}
